// Copyright 2023 Leo <lipf160627@163.com>. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.

package model

import (
	"github.com/go-playground/validator/v10"
)

// 操作带上 OperatorID，可用于检查操作者与被目标对象之间的关系，用于权限控制
type GetRequest struct {
	OperatorID uint `json:"operatorId" validate:"required"`
	ID         uint `json:"id" validate:"required"`
}

type GetResponse struct {
	ID        uint        `json:"id" validate:"required"`
	NickName  string      `json:"nickName"`
	CreatedAt int64       `json:"createAt"`
	Email     string      `json:"email" validate:"required,email"`
	Telephone string      `json:"telephone"`
	Address   UserAddress `json:"address"`
	Role      UserRole    `json:"role"`
	Credits   int         `json:"credits" validate:"gte=0"`
	Level     int         `json:"level" validate:"gte=0"`
	Age       uint        `json:"age" validate:"gte=0,lte=130"`
	Birthday  int64       `json:"birthday"`
	Message   string      `json:"message" validate:"required"`
}

func (r *GetRequest) Validate(v *validator.Validate) error {
	return v.Struct(r)
}

func (r *GetResponse) Validate(v *validator.Validate) error {
	return v.Struct(r)
}
